function handles = newFile(handles)
% newFile
%
% Editing:
% gs may 2005
% -----------------------------------------------------

% change to the 'private' directory where the default file is stored
try
    %     w = which('mapAverager1p4');
    versionName = get(handles.figure1, 'Name');
    w = which(versionName);
    w = w(1:end-2); % trims off the '.m'
    i = strfind(w, '\');
    p = [w(1:i(end)) 'private'];
    cd(p);
catch
    error(lasterr);
end

% load the default empty list
filename = 'emptyList.mat';
pathname = [p '\'];
fullname = fullfile(pathname, filename);
handles.analysis.mapAverager.cellLists.currentFile.data = load(fullname);

% now set up to save as new file in cell list file directory
try
    w = which('mapAverager1p4');
    i = strfind(w, '\');
    p = [w(1:i(end)) 'cellLists'];
    cd(p);
catch
end

% specify filename (and path)
[filename, pathname] = uiputfile('*.mat', 'Save file as:');
if isequal(filename,0)|isequal(pathname,0)
    return
end
fullname = [pathname filename '.mat'];

% filename -- store, and update in gui
handles.analysis.mapAverager.cellLists.currentFile.pname = pathname;
handles.analysis.mapAverager.cellLists.currentFile.fullname = fullname;
handles.analysis.mapAverager.cellLists.currentFile.fname = filename;
set(handles.currentFile, 'String', filename);

% % reset list displays
% set(handles.groupList, 'Value', 1);
% set(handles.cellList, 'Value', 1);

% unpack
a = fieldnames(handles.analysis.mapAverager.cellLists.currentFile.data);
listsAndExpts = eval(['handles.analysis.mapAverager.cellLists.currentFile.data.' a{1}]);
handles.analysis.mapAverager.cellLists.currentFile.listsAndExpts = listsAndExpts;

% % populate the group list listbox 
% set(handles.groupList, 'String', listsAndExpts(:,1));

% populate the cell/expt listbox -- use list for group #1 by default
if ~isempty(listsAndExpts)
    set(handles.groupList, 'Value', 1);
    set(handles.groupList, 'String', listsAndExpts(:,1));
    set(handles.cellList, 'String', listsAndExpts{1,2});
    set(handles.cellList, 'Value', 1);
else
    set(handles.groupList, 'Value', 0);
    set(handles.groupList, 'String', {});
    set(handles.cellList, 'String', {});
    set(handles.cellList, 'Value', 0);
end

% save the file
save(fullname, 'listsAndExpts');
